Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented no_std support (with/without alloc) #27

Merged
merged 22 commits into from
Dec 13, 2024
Merged

Implemented no_std support (with/without alloc) #27

merged 22 commits into from
Dec 13, 2024

Conversation

JRRudy1
Copy link
Owner

@JRRudy1 JRRudy1 commented Dec 10, 2024

This PR adds support for using the transient crate in no_std environments, with or without alloc, through the addition of new "std" and "alloc" crate features. This PR also includes CI updates that run the tests with various feature sets to ensure everything works regardless of the chosen crate features.

To enable no_std mode, disable default features using --no-default-features (or default-features = false in Cargo.toml). Almost all functionality of the transient crate will still be available, except for:

  • the downcast/downcast_unchecked methods on the dyn Any trait object (which accepts/returns a Box)
  • the Transient::erase convenience method (which accepts/returns a Box)
  • Transient impls for non-core types (particularly Box, Vec, String, and HashMap)

To enable no_std mode with alloc support, disable default features and enable the "alloc" feature using --no-default-features --features alloc (or default-features = false, features = ["alloc"] in Cargo.toml). This restores all of the functionality listed above except for the Transient impls for several types that are available in neither core nor alloc.

Resolves #25

@JRRudy1
Copy link
Owner Author

JRRudy1 commented Dec 10, 2024

@the10thWiz you may want to take a peak at this; Rocket obviously doesn't need no_std and the changes should be completely transparent, but it does slightly complicate development since std usages will need to be either replaced by core if possible or gated by cfg(feature = "std") if not

@JRRudy1
Copy link
Owner Author

JRRudy1 commented Dec 10, 2024

@the10thWiz simplified the implementation quite a bit in #28, and the changes have been pulled into this PR

Copy link
Collaborator

@the10thWiz the10thWiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty great to me. I just have one suggestion.

As pointed out by @the10thWiz, this dependency was not necessary and removing it adds flexibility.

Co-authored-by: Matthew Pomes <matthew.pomes@pm.me>
@JRRudy1 JRRudy1 merged commit 510ed10 into main Dec 13, 2024
30 checks passed
@JRRudy1 JRRudy1 deleted the no_std branch December 13, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no_std support
2 participants